#!/usr/bin/env bash

# help
#java -jar walle-cli-all.jar -h

# show channel and ext data
#java -jar walle-cli-all.jar show app.apk

# put channel and ext data to the app.apk
#java -jar walle-cli-all.jar put -c meituan app.apk
#java -jar walle-cli-all.jar put -c meituan -e buildtime=20161212,hash=xxxxxxx app.apk

# put channel from file
#java -jar walle-cli-all.jar put -c meituan app.apk app-new-hahha.apk
#java -jar walle-cli-all.jar batch -c meituan,meituan2,meituan3 app.apk
#java -jar walle-cli-all.jar batch -f channel  app.apk

# clean folder
if [ ! -d "app" ]; then
    mkdir app
fi
rm -rf app/*.apk

# blue release
if [ -f "../app/build/outputs/apk/app-redbull-release.apk" ]; then
    cp ../app/build/outputs/apk/app-redbull-release.apk app/app-redbull-release.apk
    cd app
    java -jar ../walle-cli-all.jar batch -f ../channel.blue app-redbull-release.apk
    cd ..
fi
echo "Finished blue release channel!"

# hucai release
if [ -f "../app/build/outputs/apk/app-hucai-release.apk" ]; then
    cp ../app/build/outputs/apk/app-hucai-release.apk app/app-hucai-release.apk
    cd app
    java -jar ../walle-cli-all.jar batch -f ../channel.hucai app-hucai-release.apk
    cd ..
fi
echo "Finished hucai release channel!"